<?php
	/*
	 *   Common functions used to constuct a page
	 */
	
	function createHeader($pageName, $currentPage = 0) {
		headerMenu($currentPage);
		echo("<div id=\"header\">\n");
		echo("<div id=\"logo\">\n");
		echo("	<h1><a href=\"#\">".$pageName."</a></h1>\n");
		echo("</div>\n");
		echo("<div id=\"search\">");
		echo("	<form method=\"get\" action=\"search.php\">\n");
		echo("		<fieldset>\n");
		echo("			<input type=\"text\" name=\"find\" id=\"search-text\" size=\"15\" value=\"Search Site...\" />\n");
		echo("			<input type=\"submit\" id=\"search-submit\" value=\"GO\" />\n");
		echo("		</fieldset>\n");
		echo("	</form>\n");
		echo("</div>\n");
		echo("</div>\n");
		echo("<div id=\"splash\">&nbsp;</div>\n");
		echo("<!-- end #header -->\n");	
	}
	
	function headerMenu($currentPage) {
		echo("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
		echo("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
		echo("<head>\n");
		echo("<meta name=\"keywords\" content=\"\" />\n");
		echo("<meta name=\"description\" content=\"\" />\n");
		echo("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n");
		echo("<title>HPBerry Inc.</title>\n");
		echo("<link href=\"/hpberry/style.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" />\n");
		echo("</head>\n");
		echo("<body>\n");
		echo("<div id=\"wrapper\">\n");
		echo("	<div id=\"menu\">\n");
		echo("		<ul>\n");
		if ($currentPage == 0)
			echo("			<li class=\"current_page_item\"><span><a href=\"index.php\">Home</a></span></li>\n");
		else
			echo("			<li><span><a href=\"index.php\">Home</a></span></li>\n");
		if ($currentPage == 1)
			echo("			<li class=\"current_page_item\"><a href=\"products.php\">Products</a></li>\n");
		else
			echo("			<li><a href=\"products.php\">Products</a></li>\n");
		if ($currentPage == 2)
			echo("			<li class=\"current_page_item\"><a href=\"contact.php\">Contact</a></li>\n");
		else
			echo("			<li><a href=\"contact.php\">Contact</a></li>\n");
		echo("			<!-- <li> <a href=\"/admin/login.php\">Admin</a></li> -->\n");
		echo("		</ul>\n");
		echo("	</div>\n");
		echo("<!-- end #menu -->\n");
	}
	
	function contentHeader() {
		echo("	<div id=\"page\">\n");
		echo("  <div id=\"page-bgtop\">\n");
		echo("	<div id=\"page-bgbtm\">\n");
		echo("		<div id=\"content\">\n");
	}
	
	function content($title, $image, $text) {
		echo("			<div class=\"post\">\n");
		echo("				<h2 class=\"title\"><a href=\"#\">".$title."</a></h2>\n");
		echo("				<div class=\"entry\">\n");
		echo("					<p><img src=\"images/".$image."\" width=\"143\" height=\"143\" alt=\"\" class=\"alignleft border\" />\n");
		echo("					 ".$text."</p>\n");
		echo("				</div>\n");
		echo("				<p class=\"meta\">Back to <a href=\"#\">top</a>\n");
		echo("					&nbsp;&bull;&nbsp;</p>\n");
		echo("			</div>\n");
	}
	
		
	function contentFooter() {
		echo("		<div style=\"clear: both;\">&nbsp;</div>\n");
		echo("		</div>\n");
		echo("		<!-- end #content -->\n");
		sidebar();
		echo("			<div style=\"clear: both;\">&nbsp;</div>\n");
		echo("			</div>\n");
		echo("		</div>\n");
		echo("	</div>\n");
		echo("	<!-- end #page -->\n");
		echo("</div>\n");
	}
	
	function sidebar() {
		echo("     <div id=\"sidebar\">\n");
		echo("			<ul>\n");
		echo("				<li>\n");
		echo("					<h2>Company Motto</h2>\n");
		echo("					<p>HPBerry, Inc. was founded to provide tools and services to Corporate America 
		                           and any other employers who need to protect their assets and information from 
		                           espionage and poor people. HPBerry employees take great pride in the Internet security 
		                           work that they attempt to do.</p>\n");
		echo("				</li>\n");
		echo("				<li>\n");
		echo("					<h2>Additional Content</h2>\n");
		echo("					<ul>\n");
		echo("						<li><a href=\"testimonials.php\">Testimonials</a></li>\n");
		echo("						<li><a href=\"press.php\">Press Releases</a></li>\n");
		echo("						<li><a href=\"jobs.php\">Jobs / Career Opportunities</a></li>\n");
		echo("					</ul>\n");
		echo("				</li>\n");
		echo("			</ul>\n");
		echo("		</div>\n");
		echo("		<!-- end #sidebar -->\n");
		echo("	</div>\n");
	}
	
	function footer() {
		echo("<div id=\"footer-wrapper\">\n");
		echo("<div id=\"three-columns\">\n");
		echo("	<div id=\"column1\">\n");
		echo("		<h2>Clients</h2>\n");
		echo("		<ul>\n");
		echo("			<li><a href=\"http://www.fbi.gov/\">F.B.I.</a></li>\n");
		echo("			<li><a href=\"http://www.pfizer.com/home/\">Pfizer Inc.</a></li>\n");
		echo("			<li><a href=\"https://www.bankofamerica.com/\">Bank of America</a></li>\n");
		echo("		</ul>\n");
		echo("	</div>\n");
		echo("	<div id=\"column2\">\n");
		echo("		<h2>Legal</h2>\n");
		echo("		<ul>\n");
		echo("			<li><a href=\"privacy.php\">Privacy Policy</a></li>\n");
		echo("		</ul>\n");
		echo("	</div>\n");
		echo("	<div id=\"column3\">\n");
		echo("		<h2>Affiliates</h2>\n");
		echo("		<ul>\n");
		echo("			<li><a href=\"http://rootthebox.com/\">Root the Box</a></li>\n");
		echo("			<li><a href=\"http://0x539.us/\">[BUFFER] Overflow</a></li>\n");
		echo("		</ul>\n");
		echo("	</div>\n");
		echo("  </div>\n");
		copyright();
	}
	
	function copyright() {
		echo("	<div id=\"footer\">\n");
		echo("		<p>Copyright (c) 2011 HPBerry.com. All rights reserved. </a>.</p>\n");
		echo("	</div>\n");
		echo("	<!-- end #footer -->\n");
		echo("</div>\n");
		echo("</body>\n");
		echo("</html>\n");
	}
	
	function getAllArticles() {
		$sqlConnection = mysql_connect("localhost", "aaronthebard", "StrongP@ssw0rd");
		if (!$sqlConnection)
			die("<html>OMFG Error: Unable to connect to SQL server!</html>");
		mysql_select_db("hpberry", $sqlConnection);
		$articleQuery = 'SELECT * FROM articles';
		return mysql_query($articleQuery, $sqlConnection);
	}
?>